﻿// ===============================================================================
// DotNet.Platform 开发框架 2016 版权所有
// ===============================================================================

using System;
using DotNet.Entity;
using System.ComponentModel.DataAnnotations;

namespace DotNet.Core.Entity
{
    /// <summary>
    /// 文章信息
    /// </summary>
    [Table("文章信息")]
    public class Article
    {
        /// <summary>
        /// 主键
        /// </summary>
        [PrimaryKey]
        [Column("主键", false)]
        public string Id { get; set; }

        /// <summary>
        /// 新闻分类Id
        /// </summary>
        [Column("新闻分类Id", false)]
        public string CategoryId { get; set; }

        /// <summary>
        /// 新闻分类
        /// </summary>
        [Column("新闻分类")]
        public string CategoryName { get; set; }

        /// <summary>
        /// 标题
        /// </summary>
        [Column("标题")]
        [Required(ErrorMessage = "请输入标题")]
        [MaxLength(200, ErrorMessage = "标题长度不能超过200个字符")]
        public string Subject { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        [Column("内容")]
        [Required(ErrorMessage = "请输入内容")]
        public string Contents { get; set; }

        /// <summary>
        /// 状态0待发送1已发送
        /// </summary>
        [Column("状态", Exported = false)]
        public bool Status { get; set; }

        /// <summary>
        /// 状态描述
        /// 0 待发送 1 已发送
        /// </summary>
        [Ignore]
        [Column("状态")]
        public string StatusText
        {
            get
            {
                if (Status == false)
                {
                    return "待发布";
                }
                else if (Status == true)
                {
                    return "已发布";
                }
                return "未知";
            }
        }

        /// <summary>
        /// 是否幻灯片
        /// </summary>
        [Column("是否幻灯片", Exported = false)]
        public bool IsSlide { get; set; }

        /// <summary>
        /// 是否幻灯片
        /// </summary>
        [Ignore]
        [Column("是否幻灯片")]
        public string IsSlideText
        {
            get
            {
                if (IsSlide == true)
                {
                    return "幻";
                }
                return string.Empty;
            }
        }


        /// <summary>
        /// 图片url
        /// </summary>
        [Column("图片url", Exported = false)]
        public string PhotoUrl { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        [Column("创建时间")]
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 修改时间
        /// </summary>
        [Column("修改时间")]
        public DateTime? ModifyTime { get; set; }

        /// <summary>
        /// 复制对象
        /// </summary>
        public Article Clone()
        {
            return (Article)MemberwiseClone();
        }
    }
}
